from Base import Base
from selenium.webdriver.common.by import By

class Page(Base):
    search_loc = (By.XPATH,'//*[@id="query"]')
    def search(self):
        self.send_keys(self.search_loc,'软件测试自动化')

    def title_s(self):
        return self.title()

    titlebiao_loc = (By.XPATH,'//h3[@class="vr-title  "]/a')
    def biaoti(self):
        a = self.find_elements(self.titlebiao_loc)
        print("第一页")
        for i in a:
            print(i.text)

    def biaoti2(self):
        a = self.find_elements(self.titlebiao_loc)
        print("第二页")
        for i in a:
            print(i.text)

    search_btn = (By.ID,'stb')
    def searchbtn(self):
        self.click(self.search_btn)

    next_loc = (By.ID,'sogou_next')
    def next(self):
        self.click(self.next_loc)

    def luoji_01(self):
        self.open_url('https://www.sogou.com/')
        print(self.title_s())
        try:
            assert self.title_s() == '搜索'
        except Exception as e:
            print(e)
        self.search()
        self.searchbtn()
        self.biaoti()
        try:
            assert '软件测试' in str(self.biaoti())
        except Exception as e:
            print(e)
        self.next()
        self.biaoti2()
        try:
            assert '软件测试' in str(self.biaoti2())
        except Exception as e:
            print(e)